package com.example.demo.tenant;

import javax.sql.DataSource;
import java.util.TreeMap;

/**
 * 　* @description: 用ThreadLocal来保存租户信息
 * 　* @date 2019/12/27 1:52 PM
 *
 */
public class TenantContextHolder {

    public static TreeMap<String, DataSource> dataSourceMap = new TreeMap<>();

    private static final ThreadLocal<String> CONTEXT = new ThreadLocal<>();

    public static void setTenant(String tenant) {
        CONTEXT.set(tenant);
    }

    public static String getTenant() {
        return CONTEXT.get();
    }

    public static void clear() {
        CONTEXT.remove();
    }
}
